package cn.ictgu.controller;

import cn.ictgu.dto.VideoInfo;
import cn.ictgu.parse.ParseManager;
import cn.ictgu.parse.VideoParse;
import cn.ictgu.tools.UrlUtils;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.log4j.Log4j;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.concurrent.TimeUnit;

/**
 * 视频播放
 * Created by Silence on 2017/1/7.
 */
@Log4j
@Controller
public class VideoController {

  @Autowired
  private ParseManager parseManager;

  @RequestMapping(value = "/play", method = RequestMethod.GET)
  public String play(HttpServletRequest request, Model model){
    String url = request.getParameter("v");
    url = url.replaceAll("\\?(spm|from).*" , "");
    VideoInfo videoInfo = parseManager.parseVideo(url);
    model.addAttribute("video", videoInfo);
    return "play-swf";
  }

}
